<?php


namespace catchAdmin\smstag\model\search;


trait SmsTagTrait
{
    public function searchTitleAttr($query, $value, $data)
    {
        return $query->whereLike("title", $value);
    }

    public function searchMappingFieldAttr($query, $value, $data)
    {
        return $query->whereLike("mapping_field", $value);
    }

    public function searchStartAtAttr($query, $value, $data)
    {
        return $query->whereTime('created_at', '>=', strtotime($value));
    }

    public function searchEndAtAttr($query, $value, $data)
    {
        return $query->whereTime('created_at', '<=', strtotime($value));
    }

    public function searchSmsTopicIdAttr($query, $value, $data)
    {
        return $query->whereOr([["model", "=", "Common"], ["sms_topic_id", "=", $value]]);
    }

}